<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Document</title>
</head>

<body>
  <!-- 2.准备容器 -->
  <div id="app">
    v-on语法
    <!-- v-on:事件名=”内联语句“ -->
    <button v-on:click="desc()">-</button>
    <span>{{totalCount}}</span>
    <button v-on:click="de()">+</button>
    <!-- v-on:dblclick="totalCount++",,双击加一 -->
  </div>

  <!-- 1。导入vue.js -->
  <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>

  <script>
    <!-- 3. 创建Vue实例对象 -->
    const app = new Vue({
      // < !--容器 -->
      el: "#app",
      data: {
        totalCount: 1,
      },
      methods: {
        desc() {
          if (app.totalCount === 1) {
            alert("不能再减啦");
            return;
          }
          app.totalCount--;
        },

        de() {
          if (app.totalCount === 10) {
            alert("不能在加啦");
            return;
          }
          app.totalCount++;
        },
      },
    });
  </script>
</body>

</html>